package com.sk.sqd;

import com.sk.sqd.context.Context;
import com.sk.sqd.strategy.ConcreteStrategyA;
import com.sk.sqd.strategy.ConcreteStrategyB;
import com.sk.sqd.strategy.ConcreteStrategyC;

import java.math.BigDecimal;

public class StrategyTest {

    /**
     * 因为实例化不同的策略，所以在调用 context.contextInterface(); 时，得到的结果不同
     */
    public static void main(String[] args) {
        Context context;

        context = new Context(new ConcreteStrategyA());
        context.contextInterface();

        context = new Context(new ConcreteStrategyB());
        context.contextInterface();

        context = new Context(new ConcreteStrategyC());
        context.contextInterface();

        BigDecimal money = new BigDecimal("600"); // 支付的钱
        BigDecimal condition = new BigDecimal("300"); // 消费
        BigDecimal returnMoney = new BigDecimal("100"); // 返利
//        System.out.println(bigDecimal.compareTo(returnMoney) > -1);
        System.out.println(money.divideAndRemainder(condition)[0]);
        System.out.println(money.divideAndRemainder(condition)[0].multiply(returnMoney));
        System.out.println(money.divideAndRemainder(condition)[0].multiply(returnMoney));
        System.out.println(money.subtract(money.divideAndRemainder(condition)[0].multiply(returnMoney)));

    }

}
